
<script type="text/javascript" src="geoxml3.js"></script>
<script type="text/javascript"
        src="http://maps.googleapis.com/maps/api/js?v=3.6&sensor=false&libraries=geometry">
</script>
<script type="text/javascript">
var map;
// Create a meausure object to store our markers, MVCArrays, lines and polygons
var measure = {
    mvcLine: new google.maps.MVCArray(),
    mvcPolygon: new google.maps.MVCArray(),
    mvcMarkers: new google.maps.MVCArray(),
    line: null,
    polygon: null
};

$(document).ready(function () {
    $('#kmlFile').hide();
    $('#map').hide();
    displayKmlFromDB();
});

//calculate Area
function displayKmlFromDB() {
    var kmlString = '79.9277019,6.90189411,-56.5 79.92770472,6.90213889,-84.9000015258789 79.92778434,6.90257307,-89.0 79.92753258,6.90262729,-88.5 79.92724466,6.90245269,-90.5999984741211 79.92731364,6.90211686,-88.0999984741211 79.92733411,6.9020273,-83.19999694824219 79.92716889,6.90147507,-87.80000305175781 79.92743389,6.90138298,-80.19999694824219 79.92761924,6.90177991,-89.30000305175781';
    var landId = '11';
    if (kmlString != null && kmlString.length != 0) {
        
        var kmlReferenceNumber = '99274836902046';
        var middlePoint = '79.92748379700001,6.902046816999999,-83.81';

        $('#kmlFile').show();
        $('#map').show();
        var melbourne = new google.maps.LatLng(-122.0822035425683, 37.42228990140251);
        var mapOptions = {
            zoom:      12,
            center:    melbourne,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            draggableCursor: "crosshair"
        };
        map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
        var geoXml = new geoXML3.parser({map: map, singleInfoWindow: true});

        var kml = "<kml><Placemark><name>Land</name><Polygon><extrude>1</extrude><altitudeMode>relativeToGround</altitudeMode><outerBoundaryIs><LinearRing><coordinates>" + kmlString + " </coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark><Placemark><name>" + kmlReferenceNumber + "</name><description>Geographical Center</description><Point><coordinates>" + middlePoint + "</coordinates><referenceNo>" + kmlReferenceNumber + "</referenceNo></Point></Placemark></kml>";
        // alert(kmlString);
        geoXml.parseKmlString(kml);
        //  var coordinate = new google.maps.LatLng(6.904339, 79.919087);
        // var isWithinPolygon = geoXml.containsLocation(coordinate,kml);
        //  alert(isWithinPolygon);

        /*google.maps.event.addListener(map, "click", function(evt) {
            // When the map is clicked, pass the LatLng obect to the measureAdd function
            measureAdd(evt.latLng);
        });
        var landArea = '<s:property value="land.kmlLandArea"/>';
        if (landArea == null || landArea == 0) {
            calculateAreaFromDB(landId);
        } else {
            changeHectareKml();
        }
        measureReset();
      // warning messages
       var land_not_attached = $("input#land_not_attached").val();
       var geoPoint_not_valid = $("input#geoPoint_not_valid").val();
       var geoPoint_not_in_land = $("input#geoPoint_not_in_land").val();
*/

    }
}




</script>
<tr id="kmlFile">
    <td colspan="4">
        <table>

            <tr>
                <td>
                    <div id="map">

                        <div id='map_canvas' style='height:500px; width: 750px'></div>
                    </div>
                </td>
            </tr>
        </table>
    </td>
</tr>

